﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using DTO;

namespace DAO
{
    public class PhieuGiao_DAO
    {
        public DataProvider _provider = new DataProvider();
        public PhieuGiao_DAO()
        {
            _provider.connect();
        }
        public DataTable GetDanhSachKH()
        {
            string s = "Select MaKH,TenKH,TenLoaiKH,LoaiKH.MaLoaiKH,DienThoai, DiaChi, DacDiem "
                        + "from KhachHang, LoaiKH "
                        + "where KhachHang.MaLoaiKH = LoaiKH.MaLoaiKH order by MaKH desc ";

            return _provider.executeQuery(s);
        }
        public DataTable GetDanhSachNL()
        {
            string s = "Select MaNLG,TenNLG, DVT, BangGia.Gia "
                        + " from NLG, BangGia"
                        + " where NLG.MaNLG = BangGia.MaTP_NL and BangGia.PhanLoai = 1 "
                        + " order by TenNLG DESC";
            return _provider.executeQuery(s);
        }
        public DataTable GetDanhSachTP()
        {
            string s = "Select MaTP,TenTP,BangGia.Gia "
                        + " from ThanhPham, BangGia"
                        + " where ThanhPham.MaTP = BangGia.MaTP_NL and BangGia.PhanLoai = 1 "
                        + " order by TenTP DESC";
            return _provider.executeQuery(s);
        }

        public int proc_Ins_PhieuGiao(PhieuGiao_DTO dto)
        {
            return _provider.proc_Ins_PhieuGiao(dto);
               
        }
        public void proc_Ins_CT_PhieuGiaoNL(PhieuGiao_DTO dto)
        {
             _provider.proc_Ins_CT_PhieuGiaoNL(dto);

        }
        public void proc_Ins_CT_PhieuGiaoTP(PhieuGiao_DTO dto)
        {
            _provider.proc_Ins_CT_PhieuGiaoTP(dto);

        }
        public Object GetDiaChiTheoMaKH(int MaKH)
        {
            string s = "select DiaChi from KhachHang where MaKH = "+ MaKH ;
            return _provider.executeScalar(s);
           
        }
        
    }
}
